export default {
	name: "logs-monitor",
	data() {
		return {
			firstParams: [
				{label: "编号", kind: "input", prop: "id", disabled: false},
				{label: "名称", kind: "input", prop: "name", disabled: false},
				{
					label: "级别", kind: "select", prop: "level", disabled: false,
					selectOptions: [
						{value: "1", label: "INFO"},
						{value: "2", label: "DEBUG"},
						{value: "3", label: "WARNING"},
						{value: "4", label: "ERROR"}
					]
				},
				{label: "日期", kind: "daterange", prop: "date", disabled: false}
			],
			columns: [
				{label: "编号", prop: "id", kind: "input", width: 180, sortable: true},
				{label: "名称", prop: "name", kind: "input", width: 240, sortable: true},
				{label: "日期", prop: "date", kind: "date", width: 240, sortable: true},
				{label: "级别", prop: "level", kind: "input", width: 200, sortable: false},
				{label: "描述", prop: "description", kind: "input", sortable: false}
			],
			contrast: {
				"INFO": "1",
				"DEBUG": "2",
				"WARNING": "3",
				"ERROR": "4"
			},
			stripe: false,
			isMultiple: false,
			isSum: false,
			data: []
		};
	},
	created() {
		this.addData();
	},
	methods: {
		addData() {
			for (let i = 0; i < 100; i++) {
				let name = this.randomUtils.randomString();
				let level = i % 2 === 0 ? "WARNING" : (i % 3 === 0 ? "DEBUG" : (i % 5 === 0 ? "ERROR" : "INFO"));
				let event = {
					id: this.randomUtils.randomNumber(1000, 2000),
					name: name,
					date: this.randomUtils.randomDate(),
					level: level.toUpperCase(),
					description: name + " System " + level.toUpperCase() + " Log Description "
				};
				this.data.push(event);
			}
		},
		searchData() {
			return this.$refs.searchPage.filterData(this.data);
		}
	}
};
